<?php

class HomeController extends AppController {
	
	public $name = 'Home';
	
	public $uses = array('Meshtiles');
	
	public function index() {
// 		$test = MeshtilesApi::instance()->getPhotoOfUser(array(
// 			'access_token' => $this->Auth->user('credentials.access_token'),
// 			'viewed_id' => $this->Auth->user('uid'),
// 			'page_index' => 1
// 		));

// 		$photo = $this->Meshtiles->find('all', array(
// 			'methods' => 'getPhotoOfUser',
// 			'conditions' => array(
// 				'access_token' => $this->Auth->user('credentials.access_token'),
// 				'viewed_id' => $this->Auth->user('uid'),
// 				'page_index' => 1
// 			),
// 			'fields' => array('photo')
// 		));
		
// 		$this->Tiles->buildImage(WWW_ROOT . 'img', $photoSource);
// 		$photoSource = Set::classicExtract($photo['photo'], '{n}.url_thumb');
// 		$this->Tiles = $this->Components->load('Tiles');
// 		$this->Tiles->buildImage(WWW_ROOT . 'img', $photoSource);
		
		//$this->set(compact('photo'));
	}
	
	public function notification() {
		
	}
	
	public function write() {
		$this->autoRender = false;
		
		if (!isset($this->request->query['message'])) {
			return false;
		}
		
		$memcache = new Memcache;
		
		if ($memcache->connect("localhost", 11211)) {
			$memcache->set($this->Auth->user('uid'), 'testtestes', false, 10);
		}
		
	}
}